/**
 * zmn黑名单IPjs
 * 文件命名格式：zmn.模块名称.表名称.功能.js
 * @author wangjie
 * @since 2019/06/13 13:58
 */
layui.define(['index', 'form'], function (exports) {
    let $ = layui.$;
    let layer = layui.layer;
    let form = layui.form;

    form.render(null, "zmn-form");
    //监听提交
    form.on('submit(zmn-form-submit)', function (obj) {
        $.ajax({
            async: false,
            type: "POST", url: "/blacklist/save_blacklist.action",
            contentType: "application/json", dataType: "json", data: JSON.stringify(obj.field),
            success: function (result) {
                if (result.status === 200) {
                    zmnLayUtil.closeThisIframeMsg(parent, result.message, "zmn-table");
                    parent.location.reload();
                } else {
                    layer.msg(result.message, {"icon": 2});
                }
            },
            error: function (XMLHttpRequest, treportStatus, errorThrown) {
            }
        });
        return false;
    });

    //点击取消
    $(document).on('click', '#cancel', function () {
        zmnLayUtil.closeThisIframe(parent);
    });

    //对外暴露的接口
    exports('blacklist_add', {});
});

